/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author grillo
 */
@Entity
@Table(name = "pianostudio")
@NamedQueries({@NamedQuery(name = "PianoStudio.findAll", query = "SELECT p FROM PianoStudio p"), @NamedQuery(name = "PianoStudio.findByMatricola", query = "SELECT p FROM PianoStudio p WHERE p.pianoStudioPK.matricola = :matricola"), @NamedQuery(name = "PianoStudio.findByIdesame", query = "SELECT p FROM PianoStudio p WHERE p.pianoStudioPK.idesame = :idesame"), @NamedQuery(name = "PianoStudio.findByStato", query = "SELECT p FROM PianoStudio p WHERE p.stato = :stato"), @NamedQuery(name = "PianoStudio.findByData", query = "SELECT p FROM PianoStudio p WHERE p.data = :data"), @NamedQuery(name = "PianoStudio.findByVoto", query = "SELECT p FROM PianoStudio p WHERE p.voto = :voto"), @NamedQuery(name = "PianoStudio.findByLode", query = "SELECT p FROM PianoStudio p WHERE p.lode = :lode")})
public class PianoStudio implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected PianoStudioPK pianoStudioPK;
    @Basic(optional = false)
    @Column(name = "stato")
    private boolean stato;
    @Basic(optional = true)
    @Column(name = "data")
    @Temporal(TemporalType.TIMESTAMP)
    private Date data;
    @Basic(optional = true)
    @Column(name = "voto")
    private int voto;
    @Basic(optional = true)
    @Column(name = "lode")
    private boolean lode;
    @JoinColumn(name = "idesame", referencedColumnName = "idesame", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Esame esame;
    @JoinColumn(name = "matricola", referencedColumnName = "matricola", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Studente studente;

    public PianoStudio() {
    }

    public PianoStudio(PianoStudioPK pianoStudioPK) {
        this.pianoStudioPK = pianoStudioPK;
    }

    public PianoStudio(PianoStudioPK pianoStudioPK, boolean stato, Date data, int voto, boolean lode) {
        this.pianoStudioPK = pianoStudioPK;
        this.stato = stato;
        this.data = data;
        this.voto = voto;
        this.lode = lode;
    }

    public PianoStudio(int matricola, int idesame) {
        this.pianoStudioPK = new PianoStudioPK(matricola, idesame);
    }

    public PianoStudioPK getPianoStudioPK() {
        return pianoStudioPK;
    }

    public void setPianoStudioPK(PianoStudioPK pianoStudioPK) {
        this.pianoStudioPK = pianoStudioPK;
    }

    public boolean getStato() {
        return stato;
    }

    public void setStato(boolean stato) {
        this.stato = stato;
    }

    public Date getData() {
        return data;
    }

    public void setData(Date data) {
        this.data = data;
    }

    public int getVoto() {
        return voto;
    }

    public void setVoto(int voto) {
        this.voto = voto;
    }

    public boolean getLode() {
        return lode;
    }

    public void setLode(boolean lode) {
        this.lode = lode;
    }

    public Esame getEsame() {
        return esame;
    }

    public void setEsame(Esame esame) {
        this.esame = esame;
    }

    public Studente getStudente() {
        return studente;
    }

    public void setStudente(Studente studente) {
        this.studente = studente;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (pianoStudioPK != null ? pianoStudioPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PianoStudio)) {
            return false;
        }
        PianoStudio other = (PianoStudio) object;
        if ((this.pianoStudioPK == null && other.pianoStudioPK != null) || (this.pianoStudioPK != null && !this.pianoStudioPK.equals(other.pianoStudioPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.PianoStudio[pianoStudioPK=" + pianoStudioPK + "]";
    }

}
